import { queryLoginLogList } from "@/services/system/SystemController";
import { PageContainer, ProColumns, ProTable } from "@ant-design/pro-components";
import { UAParser } from 'ua-parser-js';

const Page: React.FC = () => {
    const columns: ProColumns<System.LoginLogInfo>[] = [
        { title: 'Id', dataIndex: 'id' },
        {
            title: "登录状态", dataIndex: 'result', valueEnum: {
                0: { text: '成功', status: 'Success' },
                1: { text: '失败', status: 'Error' },
            }
        },
        { title: '登陆用户名', dataIndex: 'username' },
        { title: '登陆IP', dataIndex: 'user_ip' },
        { title: '浏览器', dataIndex: 'user_agent', render: (dom, entity) => <span>{UAParser(entity.user_agent).browser.name}</span> },
        { title: '操作系统', dataIndex: 'user_agent', render: (dom, entity) => <span>{UAParser(entity.user_agent).os.name}</span> },
        { title: '登陆时间', dataIndex: 'created_at', valueType: "dateTime" },
    ]
    return <PageContainer breadcrumbRender={false}>
        <ProTable<System.LoginLogInfo> request={queryLoginLogList} search={false} rowKey="id" columns={columns} options={{ density: false, setting: false }}        >
        </ProTable>
    </PageContainer>
}
export default Page;